home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| NWiper Show (other/nWiperShow)
| ext
| Unsupported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| C source, ASCII text, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [MPS ] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 53 63 61 6e 6e 69 6e |\section|{Scannin|
|00000010| 67 20 66 6f 72 20 75 73 | 65 73 20 6f 66 20 69 64 |g for us|es of id|
|00000020| 65 6e 74 69 66 69 65 72 | 73 7d 0d 5c 73 75 62 73 |entifier|s}.\subs|
|00000030| 65 63 74 69 6f 6e 7b 4d | 61 69 6e 20 70 72 6f 67 |ection{M|ain prog|
|00000040| 72 61 6d 7d 0d 3c 3c 2a | 3e 3e 3d 0d 23 69 6e 63 |ram}.<<*|>>=.#inc|
|00000050| 6c 75 64 65 20 3c 73 74 | 64 69 6f 2e 68 3e 0d 23 |lude <st|dio.h>.#|
|00000060| 69 6e 63 6c 75 64 65 20 | 3c 73 74 64 6c 69 62 2e |include |<stdlib.|
|00000070| 68 3e 0d 23 69 6e 63 6c | 75 64 65 20 3c 73 74 72 |h>.#incl|ude <str|
|00000080| 69 6e 67 2e 68 3e 0d 23 | 69 6e 63 6c 75 64 65 20 |ing.h>.#|include |
|00000090| 3c 63 74 79 70 65 2e 68 | 3e 0d 23 69 6e 63 6c 75 |<ctype.h|>.#inclu|
|000000a0| 64 65 20 22 65 72 72 6f | 72 73 2e 68 22 0d 23 69 |de "erro|rs.h".#i|
|000000b0| 6e 63 6c 75 64 65 20 22 | 6d 61 74 63 68 2e 68 22 |nclude "|match.h"|
|000000c0| 0d 23 69 6e 63 6c 75 64 | 65 20 22 67 65 74 6c 69 |.#includ|e "getli|
|000000d0| 6e 65 2e 68 22 0d 23 69 | 6e 63 6c 75 64 65 20 22 |ne.h".#i|nclude "|
|000000e0| 72 65 63 6f 67 6e 69 7a | 65 2e 68 22 0d 40 0d 54 |recogniz|e.h".@.T|
|000000f0| 68 65 73 65 20 63 68 6f | 69 63 65 73 20 6f 66 20 |hese cho|ices of |
|00000100| 61 6c 70 68 61 6e 75 6d | 65 72 69 63 73 20 61 6e |alphanum|erics an|
|00000110| 64 20 73 79 6d 62 6f 6c | 73 20 73 65 65 6d 20 74 |d symbol|s seem t|
|00000120| 6f 20 77 6f 72 6b 20 66 | 6f 72 20 6d 6f 73 74 20 |o work f|or most |
|00000130| 6c 61 6e 67 75 61 67 65 | 73 2e 0d 4d 61 6b 69 6e |language|s..Makin|
|00000140| 67 20 5b 5b 40 5d 5d 20 | 61 6c 70 68 61 6e 75 6d |g [[@]] |alphanum|
|00000150| 65 72 69 63 20 68 65 6c | 70 73 20 7b 5c 4c 61 54 |eric hel|ps {\LaT|
|00000160| 65 58 7d 2c 20 61 6e 64 | 20 6d 61 6b 69 6e 67 20 |eX}, and| making |
|00000170| 5b 5b 23 5d 5d 0d 61 6c | 70 68 61 6e 75 6d 65 72 |[[#]].al|phanumer|
|00000180| 69 63 20 68 65 6c 70 73 | 20 61 76 6f 69 64 20 66 |ic helps| avoid f|
|00000190| 61 6c 73 65 20 68 69 74 | 73 20 6f 6e 20 43 20 70 |alse hit|s on C p|
|000001a0| 72 65 70 72 6f 63 65 73 | 73 6f 72 20 64 69 72 65 |reproces|sor dire|
|000001b0| 63 74 69 76 65 73 20 6c | 69 6b 65 0d 5b 5b 23 64 |ctives l|ike.[[#d|
|000001c0| 65 66 69 6e 65 5d 5d 20 | 61 6e 64 20 5b 5b 23 69 |efine]] |and [[#i|
|000001d0| 6e 63 6c 75 64 65 5d 5d | 2e 0d 3c 3c 2a 3e 3e 3d |nclude]]|..<<*>>=|
|000001e0| 0d 73 74 61 74 69 63 20 | 52 65 63 6f 67 6e 69 7a |.static |Recogniz|
|000001f0| 65 72 20 6e 77 69 6e 64 | 65 78 3b 0d 23 64 65 66 |er nwind|ex;.#def|
|00000200| 69 6e 65 20 41 4c 50 48 | 41 4e 55 4d 20 22 5f 27 |ine ALPH|ANUM "_'|
|00000210| 40 41 42 43 44 45 46 47 | 48 49 4a 4b 4c 4d 4e 4f |@ABCDEFG|HIJKLMNO|
|00000220| 50 51 52 53 54 55 56 57 | 58 59 5a 61 62 63 64 65 |PQRSTUVW|XYZabcde|
|00000230| 66 67 68 69 6a 6b 6c 6d | 6e 6f 70 71 72 73 74 75 |fghijklm|nopqrstu|
|00000240| 76 77 78 79 7a 30 31 32 | 33 34 35 36 37 38 39 23 |vwxyz012|3456789#|
|00000250| 22 0d 23 64 65 66 69 6e | 65 20 53 59 4d 42 4f 4c |".#defin|e SYMBOL|
|00000260| 53 20 22 21 25 5e 26 2a | 2d 2b 3a 3d 7c 7e 3c 3e |S "!%^&*|-+:=|~<>|
|00000270| 2e 2f 3f 60 22 0d 2f 2a | 20 6e 6f 74 65 20 24 20 |./?`"./*| note $ |
|00000280| 61 6e 64 20 5c 20 62 6f | 74 68 20 64 65 6c 69 6d |and \ bo|th delim|
|00000290| 69 74 65 72 73 20 2a 2f | 0d 40 20 25 64 65 66 20 |iters */|.@ %def |
|000002a0| 41 4c 50 48 41 4e 55 4d | 20 53 59 4d 42 4f 4c 53 |ALPHANUM| SYMBOLS|
|000002b0| 0d 0d 42 79 20 64 65 66 | 61 75 6c 74 2c 20 66 69 |..By def|ault, fi|
|000002c0| 6e 64 20 75 73 65 73 20 | 77 69 74 68 69 6e 20 71 |nd uses |within q|
|000002d0| 75 6f 74 65 64 20 63 6f | 64 65 20 28 5b 5b 5b 5b |uoted co|de ([[[[|
|000002e0| 2e 2e 2e 5d 5d 5d 5d 29 | 2e 0d 3c 3c 2a 3e 3e 3d |...]]]])|..<<*>>=|
|000002f0| 0d 73 74 61 74 69 63 20 | 69 6e 74 20 73 68 6f 77 |.static |int show|
|00000300| 71 75 6f 74 65 73 20 3d | 20 31 3b 0d 3c 3c 74 79 |quotes =| 1;.<<ty|
|00000310| 70 65 64 65 66 73 3e 3e | 0d 3c 3c 6c 6f 63 61 6c |pedefs>>|.<<local|
|00000320| 20 70 72 6f 74 6f 74 79 | 70 65 73 3e 3e 0d 3c 3c | prototy|pes>>.<<|
|00000330| 2a 3e 3e 3d 0d 6d 61 69 | 6e 28 69 6e 74 20 61 72 |*>>=.mai|n(int ar|
|00000340| 67 63 2c 20 63 68 61 72 | 20 2a 2a 61 72 67 76 29 |gc, char| **argv)|
|00000350| 20 7b 0d 20 20 20 20 46 | 49 4c 45 20 2a 66 70 3b | {. F|ILE *fp;|
|00000360| 0d 20 20 20 20 63 68 61 | 72 20 2a 6d 79 73 65 6c |. cha|r *mysel|
|00000370| 66 20 3d 20 2a 61 72 67 | 76 3b 0d 20 20 20 20 69 |f = *arg|v;. i|
|00000380| 6e 74 20 69 3b 0d 0d 20 | 20 20 20 66 6f 72 20 28 |nt i;.. | for (|
|00000390| 69 20 3d 20 31 3b 20 69 | 20 3c 20 61 72 67 63 20 |i = 1; i| < argc |
|000003a0| 26 26 20 61 72 67 76 5b | 69 5d 5b 30 5d 20 3d 3d |&& argv[|i][0] ==|
|000003b0| 20 27 2d 27 20 26 26 20 | 61 72 67 76 5b 69 5d 5b | '-' && |argv[i][|
|000003c0| 31 5d 20 21 3d 20 30 3b | 20 69 2b 2b 29 0d 20 20 |1] != 0;| i++). |
|000003d0| 20 20 20 20 20 20 69 66 | 20 28 21 73 74 72 63 6d | if| (!strcm|
|000003e0| 70 28 61 72 67 76 5b 69 | 5d 2c 20 22 2d 6e 6f 71 |p(argv[i|], "-noq|
|000003f0| 75 6f 74 65 22 29 29 0d | 20 20 20 20 20 20 20 20 |uote")).| |
|00000400| 20 20 20 20 73 68 6f 77 | 71 75 6f 74 65 73 20 3d | show|quotes =|
|00000410| 20 30 3b 0d 20 20 20 20 | 20 20 20 20 65 6c 73 65 | 0;. | else|
|00000420| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 65 72 72 |. | err|
|00000430| 6f 72 6d 73 67 28 45 72 | 72 6f 72 2c 20 22 25 73 |ormsg(Er|ror, "%s|
|00000440| 3a 20 75 6e 6b 6e 6f 77 | 6e 20 6f 70 74 69 6f 6e |: unknow|n option|
|00000450| 20 2d 25 63 5c 6e 22 2c | 20 6d 79 73 65 6c 66 2c | -%c\n",| myself,|
|00000460| 20 61 72 67 76 5b 69 5d | 5b 31 5d 29 3b 0d 20 20 | argv[i]|[1]);. |
|00000470| 20 20 6e 77 69 6e 64 65 | 78 20 3d 20 6e 65 77 5f | nwinde|x = new_|
|00000480| 72 65 63 6f 67 6e 69 7a | 65 72 28 41 4c 50 48 41 |recogniz|er(ALPHA|
|00000490| 4e 55 4d 2c 20 53 59 4d | 42 4f 4c 53 29 3b 0d 20 |NUM, SYM|BOLS);. |
|000004a0| 20 20 20 69 66 20 28 69 | 20 3d 3d 20 61 72 67 63 | if (i| == argc|
|000004b0| 29 20 7b 0d 20 20 20 20 | 20 20 20 3c 3c 61 64 64 |) {. | <<add|
|000004c0| 20 75 73 65 73 20 74 6f | 20 73 74 64 69 6e 2c 20 | uses to| stdin, |
|000004d0| 67 72 61 62 62 69 6e 67 | 20 64 65 66 6e 73 20 66 |grabbing| defns f|
|000004e0| 72 6f 6d 20 73 74 64 69 | 6e 3e 3e 0d 20 20 20 20 |rom stdi|n>>. |
|000004f0| 7d 20 65 6c 73 65 20 7b | 0d 20 20 20 20 20 20 20 |} else {|. |
|00000500| 3c 3c 72 65 61 64 20 69 | 64 65 6e 74 69 66 69 65 |<<read i|dentifie|
|00000510| 72 73 20 74 6f 20 62 65 | 20 64 65 66 69 6e 65 64 |rs to be| defined|
|00000520| 20 66 72 6f 6d 20 66 69 | 6c 65 73 20 6e 61 6d 65 | from fi|les name|
|00000530| 64 20 69 6e 20 5b 5b 61 | 72 67 76 5d 5d 3e 3e 0d |d in [[a|rgv]]>>.|
|00000540| 20 20 20 20 20 20 20 73 | 74 6f 70 5f 61 64 64 69 | s|top_addi|
|00000550| 6e 67 28 6e 77 69 6e 64 | 65 78 29 3b 0d 20 20 20 |ng(nwind|ex);. |
|00000560| 20 20 20 20 61 64 64 5f | 75 73 65 5f 6d 61 72 6b | add_|use_mark|
|00000570| 65 72 73 28 73 74 64 69 | 6e 2c 20 73 74 64 6f 75 |ers(stdi|n, stdou|
|00000580| 74 29 3b 0d 20 20 20 20 | 7d 0d 20 20 20 20 65 78 |t);. |}. ex|
|00000590| 69 74 28 65 72 72 6f 72 | 6c 65 76 65 6c 29 3b 0d |it(error|level);.|
|000005a0| 20 20 20 20 72 65 74 75 | 72 6e 20 65 72 72 6f 72 | retu|rn error|
|000005b0| 6c 65 76 65 6c 3b 09 09 | 2f 2a 20 73 6c 61 79 20 |level;..|/* slay |
|000005c0| 77 61 72 6e 69 6e 67 20 | 2a 2f 0d 7d 0d 40 0d 3c |warning |*/.}.@.<|
|000005d0| 3c 72 65 61 64 20 69 64 | 65 6e 74 69 66 69 65 72 |<read id|entifier|
|000005e0| 73 20 74 6f 20 62 65 20 | 64 65 66 69 6e 65 64 20 |s to be |defined |
|000005f0| 66 72 6f 6d 20 66 69 6c | 65 73 20 6e 61 6d 65 64 |from fil|es named|
|00000600| 20 69 6e 20 5b 5b 61 72 | 67 76 5d 5d 3e 3e 3d 0d | in [[ar|gv]]>>=.|
|00000610| 66 6f 72 20 28 3b 20 69 | 20 3c 20 61 72 67 63 3b |for (; i| < argc;|
|00000620| 20 69 2b 2b 29 0d 20 20 | 20 20 69 66 20 28 28 66 | i++). | if ((f|
|00000630| 70 3d 66 6f 70 65 6e 28 | 61 72 67 76 5b 69 5d 2c |p=fopen(|argv[i],|
|00000640| 22 72 22 29 29 3d 3d 4e | 55 4c 4c 29 0d 20 20 20 |"r"))==N|ULL). |
|00000650| 20 20 20 20 20 65 72 72 | 6f 72 6d 73 67 28 45 72 | err|ormsg(Er|
|00000660| 72 6f 72 2c 20 22 25 73 | 3a 20 63 6f 75 6c 64 6e |ror, "%s|: couldn|
|00000670| 27 74 20 6f 70 65 6e 20 | 66 69 6c 65 20 25 73 5c |'t open |file %s\|
|00000680| 6e 22 2c 20 6d 79 73 65 | 6c 66 2c 20 61 72 67 76 |n", myse|lf, argv|
|00000690| 5b 69 5d 29 3b 0d 20 20 | 20 20 65 6c 73 65 20 7b |[i]);. | else {|
|000006a0| 0d 20 20 20 20 20 20 20 | 20 72 65 61 64 5f 69 64 |. | read_id|
|000006b0| 73 28 66 70 29 3b 0d 20 | 20 20 20 20 20 20 20 66 |s(fp);. | f|
|000006c0| 63 6c 6f 73 65 28 66 70 | 29 3b 0d 20 20 20 20 7d |close(fp|);. }|
|000006d0| 0d 3c 3c 6c 6f 63 61 6c | 20 70 72 6f 74 6f 74 79 |.<<local| prototy|
|000006e0| 70 65 73 3e 3e 3d 0d 73 | 74 61 74 69 63 20 76 6f |pes>>=.s|tatic vo|
|000006f0| 69 64 20 72 65 61 64 5f | 69 64 73 28 46 49 4c 45 |id read_|ids(FILE|
|00000700| 20 2a 69 6e 29 3b 0d 3c | 3c 2a 3e 3e 3d 0d 73 74 | *in);.<|<*>>=.st|
|00000710| 61 74 69 63 20 76 6f 69 | 64 20 72 65 61 64 5f 69 |atic voi|d read_i|
|00000720| 64 73 28 46 49 4c 45 20 | 2a 69 6e 29 20 7b 0d 20 |ds(FILE |*in) {. |
|00000730| 20 20 20 63 68 61 72 20 | 2a 6c 69 6e 65 3b 0d 20 | char |*line;. |
|00000740| 20 20 20 77 68 69 6c 65 | 20 28 28 6c 69 6e 65 20 | while| ((line |
|00000750| 3d 20 67 65 74 6c 69 6e | 65 28 69 6e 29 29 20 21 |= getlin|e(in)) !|
|00000760| 3d 20 4e 55 4c 4c 29 20 | 7b 0d 20 20 20 20 20 20 |= NULL) |{. |
|00000770| 20 20 69 66 20 28 6c 69 | 6e 65 5b 73 74 72 6c 65 | if (li|ne[strle|
|00000780| 6e 28 6c 69 6e 65 29 2d | 31 5d 20 3d 3d 20 27 5c |n(line)-|1] == '\|
|00000790| 6e 27 29 20 6c 69 6e 65 | 5b 73 74 72 6c 65 6e 28 |n') line|[strlen(|
|000007a0| 6c 69 6e 65 29 2d 31 5d | 20 3d 20 30 3b 0d 20 20 |line)-1]| = 0;. |
|000007b0| 20 20 20 20 20 20 61 64 | 64 5f 69 64 65 6e 74 28 | ad|d_ident(|
|000007c0| 6e 77 69 6e 64 65 78 2c | 20 6c 69 6e 65 29 3b 0d |nwindex,| line);.|
|000007d0| 20 20 20 20 7d 0d 7d 0d | 40 20 25 64 65 66 20 72 | }.}.|@ %def r|
|000007e0| 65 61 64 5f 69 64 73 0d | 3c 3c 61 64 64 20 75 73 |ead_ids.|<<add us|
|000007f0| 65 73 20 74 6f 20 73 74 | 64 69 6e 2c 20 67 72 61 |es to st|din, gra|
|00000800| 62 62 69 6e 67 20 64 65 | 66 6e 73 20 66 72 6f 6d |bbing de|fns from|
|00000810| 20 73 74 64 69 6e 3e 3e | 3d 0d 7b 20 20 20 46 49 | stdin>>|=.{ FI|
|00000820| 4c 45 20 2a 74 6d 70 20 | 3d 20 74 6d 70 66 69 6c |LE *tmp |= tmpfil|
|00000830| 65 28 29 3b 0d 20 20 20 | 20 63 68 61 72 20 2a 6c |e();. | char *l|
|00000840| 69 6e 65 3b 0d 20 20 20 | 20 69 66 20 28 74 6d 70 |ine;. | if (tmp|
|00000850| 20 3d 3d 20 4e 55 4c 4c | 29 20 3c 3c 63 6f 6d 70 | == NULL|) <<comp|
|00000860| 6c 61 69 6e 20 61 62 6f | 75 74 20 6f 70 65 6e 69 |lain abo|ut openi|
|00000870| 6e 67 20 74 65 6d 70 20 | 66 69 6c 65 20 61 6e 64 |ng temp |file and|
|00000880| 20 65 78 69 74 3e 3e 0d | 20 20 20 20 77 68 69 6c | exit>>.| whil|
|00000890| 65 20 28 28 6c 69 6e 65 | 20 3d 20 67 65 74 6c 69 |e ((line| = getli|
|000008a0| 6e 65 28 73 74 64 69 6e | 29 29 20 21 3d 20 4e 55 |ne(stdin|)) != NU|
|000008b0| 4c 4c 29 20 7b 0d 20 20 | 20 20 20 20 20 20 69 66 |LL) {. | if|
|000008c0| 20 28 66 70 75 74 73 28 | 6c 69 6e 65 2c 20 74 6d | (fputs(|line, tm|
|000008d0| 70 29 20 3d 3d 20 45 4f | 46 29 20 3c 3c 63 6f 6d |p) == EO|F) <<com|
|000008e0| 70 6c 61 69 6e 20 61 62 | 6f 75 74 20 77 72 69 74 |plain ab|out writ|
|000008f0| 69 6e 67 20 74 65 6d 70 | 20 66 69 6c 65 20 61 6e |ing temp| file an|
|00000900| 64 20 65 78 69 74 3e 3e | 0d 20 20 20 20 20 20 20 |d exit>>|. |
|00000910| 20 69 66 20 28 69 73 5f | 69 6e 64 65 78 28 6c 69 | if (is_|index(li|
|00000920| 6e 65 2c 20 22 64 65 66 | 6e 22 29 29 20 7b 0d 20 |ne, "def|n")) {. |
|00000930| 20 20 20 20 20 20 20 20 | 20 20 20 69 66 20 28 6c | | if (l|
|00000940| 69 6e 65 5b 73 74 72 6c | 65 6e 28 6c 69 6e 65 29 |ine[strl|en(line)|
|00000950| 2d 31 5d 20 3d 3d 20 27 | 5c 6e 27 29 20 6c 69 6e |-1] == '|\n') lin|
|00000960| 65 5b 73 74 72 6c 65 6e | 28 6c 69 6e 65 29 2d 31 |e[strlen|(line)-1|
|00000970| 5d 20 3d 20 30 3b 0d 20 | 20 20 20 20 20 20 20 20 |] = 0;. | |
|00000980| 20 20 20 61 64 64 5f 69 | 64 65 6e 74 28 6e 77 69 | add_i|dent(nwi|
|00000990| 6e 64 65 78 2c 20 6c 69 | 6e 65 2b 31 2b 35 2b 31 |ndex, li|ne+1+5+1|
|000009a0| 2b 34 2b 31 29 3b 0d 20 | 20 20 20 20 20 20 20 7d |+4+1);. | }|
|000009b0| 20 65 6c 73 65 20 69 66 | 20 28 69 73 5f 69 6e 64 | else if| (is_ind|
|000009c0| 65 78 28 6c 69 6e 65 2c | 20 22 6c 6f 63 61 6c 64 |ex(line,| "locald|
|000009d0| 65 66 6e 22 29 29 20 7b | 0d 20 20 20 20 20 20 20 |efn")) {|. |
|000009e0| 20 20 20 20 20 69 66 20 | 28 6c 69 6e 65 5b 73 74 | if |(line[st|
|000009f0| 72 6c 65 6e 28 6c 69 6e | 65 29 2d 31 5d 20 3d 3d |rlen(lin|e)-1] ==|
|00000a00| 20 27 5c 6e 27 29 20 6c | 69 6e 65 5b 73 74 72 6c | '\n') l|ine[strl|
|00000a10| 65 6e 28 6c 69 6e 65 29 | 2d 31 5d 20 3d 20 30 3b |en(line)|-1] = 0;|
|00000a20| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 61 64 64 |. | add|
|00000a30| 5f 69 64 65 6e 74 28 6e | 77 69 6e 64 65 78 2c 20 |_ident(n|windex, |
|00000a40| 6c 69 6e 65 2b 31 2b 35 | 2b 31 2b 39 2b 31 29 3b |line+1+5|+1+9+1);|
|00000a50| 0d 20 20 20 20 20 20 20 | 20 7d 0d 20 20 20 20 7d |. | }. }|
|00000a60| 0d 20 20 20 20 72 65 77 | 69 6e 64 28 74 6d 70 29 |. rew|ind(tmp)|
|00000a70| 3b 0d 20 20 20 20 73 74 | 6f 70 5f 61 64 64 69 6e |;. st|op_addin|
|00000a80| 67 28 6e 77 69 6e 64 65 | 78 29 3b 0d 20 20 20 20 |g(nwinde|x);. |
|00000a90| 61 64 64 5f 75 73 65 5f | 6d 61 72 6b 65 72 73 28 |add_use_|markers(|
|00000aa0| 74 6d 70 2c 20 73 74 64 | 6f 75 74 29 3b 0d 7d 0d |tmp, std|out);.}.|
|00000ab0| 3c 3c 74 79 70 65 64 65 | 66 73 3e 3e 3d 0d 74 79 |<<typede|fs>>=.ty|
|00000ac0| 70 65 64 65 66 20 73 74 | 72 75 63 74 20 6c 69 6e |pedef st|ruct lin|
|00000ad0| 65 5f 61 6e 64 5f 6f 75 | 74 66 69 6c 65 20 7b 0d |e_and_ou|tfile {.|
|00000ae0| 20 20 20 20 63 68 61 72 | 20 2a 6c 69 6e 65 3b 0d | char| *line;.|
|00000af0| 20 20 20 20 46 49 4c 45 | 20 2a 6f 75 74 3b 0d 7d | FILE| *out;.}|
|00000b00| 20 4c 69 6e 65 4f 75 74 | 3b 0d 3c 3c 6c 6f 63 61 | LineOut|;.<<loca|
|00000b10| 6c 20 70 72 6f 74 6f 74 | 79 70 65 73 3e 3e 3d 0d |l protot|ypes>>=.|
|00000b20| 73 74 61 74 69 63 20 76 | 6f 69 64 20 61 64 64 5f |static v|oid add_|
|00000b30| 75 73 65 5f 6d 61 72 6b | 65 72 73 28 46 49 4c 45 |use_mark|ers(FILE|
|00000b40| 20 2a 69 6e 2c 20 46 49 | 4c 45 20 2a 6f 75 74 29 | *in, FI|LE *out)|
|00000b50| 3b 0d 3c 3c 2a 3e 3e 3d | 0d 73 74 61 74 69 63 20 |;.<<*>>=|.static |
|00000b60| 76 6f 69 64 20 61 64 64 | 5f 75 73 65 5f 6d 61 72 |void add|_use_mar|
|00000b70| 6b 65 72 73 28 46 49 4c | 45 20 2a 69 6e 2c 20 46 |kers(FIL|E *in, F|
|00000b80| 49 4c 45 20 2a 6f 75 74 | 29 20 7b 0d 20 20 20 20 |ILE *out|) {. |
|00000b90| 63 68 61 72 20 2a 6c 69 | 6e 65 3b 0d 20 20 20 20 |char *li|ne;. |
|00000ba0| 69 6e 74 20 69 6e 63 6f | 64 65 20 3d 20 30 3b 0d |int inco|de = 0;.|
|00000bb0| 20 20 20 20 4c 69 6e 65 | 4f 75 74 20 69 6e 66 6f | Line|Out info|
|00000bc0| 3b 20 69 6e 66 6f 2e 6c | 69 6e 65 20 3d 20 28 63 |; info.l|ine = (c|
|00000bd0| 68 61 72 20 2a 29 30 3b | 20 69 6e 66 6f 2e 6f 75 |har *)0;| info.ou|
|00000be0| 74 20 3d 20 6f 75 74 3b | 0d 20 20 20 20 0d 20 20 |t = out;|. . |
|00000bf0| 20 20 77 68 69 6c 65 20 | 28 28 6c 69 6e 65 20 3d | while |((line =|
|00000c00| 20 67 65 74 6c 69 6e 65 | 28 69 6e 29 29 20 21 3d | getline|(in)) !=|
|00000c10| 20 4e 55 4c 4c 29 20 7b | 0d 20 20 20 20 20 20 20 | NULL) {|. |
|00000c20| 20 69 66 20 28 69 73 5f | 62 65 67 69 6e 28 6c 69 | if (is_|begin(li|
|00000c30| 6e 65 2c 20 22 63 6f 64 | 65 22 29 20 7c 7c 20 73 |ne, "cod|e") || s|
|00000c40| 68 6f 77 71 75 6f 74 65 | 73 20 26 26 20 69 73 5f |howquote|s && is_|
|00000c50| 6b 65 79 77 6f 72 64 28 | 6c 69 6e 65 2c 20 22 71 |keyword(|line, "q|
|00000c60| 75 6f 74 65 22 29 29 0d | 09 20 20 20 20 69 6e 63 |uote")).|. inc|
|00000c70| 6f 64 65 20 3d 20 31 3b | 0d 09 65 6c 73 65 20 69 |ode = 1;|..else i|
|00000c80| 66 20 28 69 73 5f 65 6e | 64 28 6c 69 6e 65 2c 20 |f (is_en|d(line, |
|00000c90| 22 63 6f 64 65 22 29 20 | 7c 7c 20 69 73 5f 6b 65 |"code") ||| is_ke|
|00000ca0| 79 77 6f 72 64 28 6c 69 | 6e 65 2c 20 22 65 6e 64 |yword(li|ne, "end|
|00000cb0| 71 75 6f 74 65 22 29 29 | 0d 09 20 20 20 20 69 6e |quote"))|.. in|
|00000cc0| 63 6f 64 65 20 3d 20 30 | 3b 0d 09 69 66 20 28 69 |code = 0|;..if (i|
|00000cd0| 73 5f 6b 65 79 77 6f 72 | 64 28 6c 69 6e 65 2c 20 |s_keywor|d(line, |
|00000ce0| 22 74 65 78 74 22 29 20 | 26 26 20 69 6e 63 6f 64 |"text") |&& incod|
|00000cf0| 65 29 20 7b 0d 09 20 20 | 20 20 69 6e 66 6f 2e 6c |e) {.. | info.l|
|00000d00| 69 6e 65 20 3d 20 6c 69 | 6e 65 20 2b 20 36 3b 20 |ine = li|ne + 6; |
|00000d10| 2f 2a 20 73 6b 69 70 20 | 22 40 74 65 78 74 20 22 |/* skip |"@text "|
|00000d20| 20 2a 2f 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 | */. | |
|00000d30| 73 65 61 72 63 68 5f 66 | 6f 72 5f 69 64 65 6e 74 |search_f|or_ident|
|00000d40| 28 6e 77 69 6e 64 65 78 | 2c 20 6c 69 6e 65 2c 20 |(nwindex|, line, |
|00000d50| 77 72 69 74 65 5f 69 6e | 64 65 78 5f 75 73 65 2c |write_in|dex_use,|
|00000d60| 20 26 69 6e 66 6f 29 3b | 0d 20 20 20 20 20 20 20 | &info);|. |
|00000d70| 20 20 20 20 20 69 66 20 | 28 2a 69 6e 66 6f 2e 6c | if |(*info.l|
|00000d80| 69 6e 65 20 26 26 20 2a | 69 6e 66 6f 2e 6c 69 6e |ine && *|info.lin|
|00000d90| 65 20 21 3d 20 27 5c 6e | 27 29 20 0d 09 09 66 70 |e != '\n|') ...fp|
|00000da0| 72 69 6e 74 66 28 6f 75 | 74 2c 20 22 40 74 65 78 |rintf(ou|t, "@tex|
|00000db0| 74 20 25 73 22 2c 20 69 | 6e 66 6f 2e 6c 69 6e 65 |t %s", i|nfo.line|
|00000dc0| 29 3b 09 2f 2a 20 68 61 | 73 20 6e 65 77 6c 69 6e |);./* ha|s newlin|
|00000dd0| 65 20 2a 2f 0d 09 7d 20 | 65 6c 73 65 0d 09 20 20 |e */..} |else.. |
|00000de0| 20 20 66 70 72 69 6e 74 | 66 28 6f 75 74 2c 20 22 | fprint|f(out, "|
|00000df0| 25 73 22 2c 20 6c 69 6e | 65 29 3b 0d 20 20 20 20 |%s", lin|e);. |
|00000e00| 7d 09 20 20 20 20 0d 7d | 0d 40 20 25 64 65 66 20 |}. .}|.@ %def |
|00000e10| 61 64 64 5f 75 73 65 5f | 6d 61 72 6b 65 72 73 0d |add_use_|markers.|
|00000e20| 0d 57 65 20 67 72 61 64 | 75 61 6c 6c 79 20 63 75 |.We grad|ually cu|
|00000e30| 74 20 6f 75 74 20 74 68 | 65 20 75 73 65 73 2c 20 |t out th|e uses, |
|00000e40| 61 6e 64 20 74 68 65 20 | 74 61 69 6c 20 6f 66 20 |and the |tail of |
|00000e50| 74 68 65 20 6c 69 6e 65 | 20 69 73 20 6c 65 66 74 |the line| is left|
|00000e60| 20 69 6e 20 5b 5b 69 6e | 66 6f 2e 6c 69 6e 65 5d | in [[in|fo.line]|
|00000e70| 5d 2c 0d 74 6f 20 62 65 | 20 70 72 69 6e 74 65 64 |],.to be| printed|
|00000e80| 20 62 79 20 74 68 65 20 | 63 6f 64 65 20 61 62 6f | by the |code abo|
|00000e90| 76 65 2e 0d 54 68 65 72 | 65 27 73 20 61 20 74 72 |ve..Ther|e's a tr|
|00000ea0| 69 63 6b 79 20 62 75 67 | 20 6c 75 72 6b 69 6e 67 |icky bug| lurking|
|00000eb0| 20 68 65 72 65 2d 2d 2d | 69 66 20 6f 6e 65 20 69 | here---|if one i|
|00000ec0| 64 65 6e 74 69 66 69 65 | 72 20 69 73 20 61 20 70 |dentifie|r is a p|
|00000ed0| 72 65 66 69 78 20 6f 66 | 20 61 6e 6f 74 68 65 72 |refix of| another|
|00000ee0| 2c 0d 62 75 74 20 62 6f | 74 68 20 61 72 65 20 72 |,.but bo|th are r|
|00000ef0| 65 63 6f 67 6e 69 7a 65 | 64 20 28 61 73 20 77 69 |ecognize|d (as wi|
|00000f00| 74 68 20 74 68 65 20 43 | 24 2b 2b 24 20 5b 5b 3a |th the C|$++$ [[:|
|00000f10| 3a 5d 5d 20 73 65 70 61 | 72 61 74 6f 72 29 2c 20 |:]] sepa|rator), |
|00000f20| 77 65 20 68 61 76 65 20 | 74 6f 20 61 76 6f 69 64 |we have |to avoid|
|00000f30| 0d 77 72 69 74 69 6e 67 | 20 74 68 65 6d 20 62 6f |.writing| them bo|
|00000f40| 74 68 20 6f 75 74 20 69 | 6e 20 66 75 6c 6c 2c 20 |th out i|n full, |
|00000f50| 62 65 63 61 75 73 65 20 | 74 68 61 74 20 77 6f 75 |because |that wou|
|00000f60| 6c 64 20 64 75 70 6c 69 | 63 61 74 65 20 74 65 78 |ld dupli|cate tex|
|00000f70| 74 20 75 6e 6e 65 63 65 | 73 73 61 72 69 6c 79 2e |t unnece|ssarily.|
|00000f80| 0d 41 73 20 61 20 72 65 | 73 75 6c 74 2c 20 77 65 |.As a re|sult, we|
|00000f90| 20 61 6c 77 61 79 73 20 | 65 6d 69 74 20 74 68 65 | always |emit the|
|00000fa0| 20 6c 69 6e 65 20 69 6e | 20 70 69 65 63 65 73 2e | line in| pieces.|
|00000fb0| 0d 54 68 65 20 66 75 6e | 63 74 69 6f 6e 20 5b 5b |.The fun|ction [[|
|00000fc0| 65 6d 69 74 5f 75 70 5f | 74 6f 28 66 2c 20 73 2c |emit_up_|to(f, s,|
|00000fd0| 20 6c 69 6d 69 74 29 5d | 5d 20 65 6d 69 74 73 20 | limit)]|] emits |
|00000fe0| 74 68 65 20 70 69 65 63 | 65 20 6f 66 20 74 68 65 |the piec|e of the|
|00000ff0| 20 73 74 72 69 6e 67 20 | 5b 5b 73 5d 5d 20 75 70 | string |[[s]] up|
|00001000| 20 74 6f 20 0d 62 75 74 | 20 6e 6f 74 20 69 6e 63 | to .but| not inc|
|00001010| 6c 75 64 69 6e 67 20 5b | 5b 6c 69 6d 69 74 5d 5d |luding [|[limit]]|
|00001020| 2c 20 69 66 20 61 6e 79 | 2e 0d 49 74 20 72 65 74 |, if any|..It ret|
|00001030| 75 72 6e 73 20 5b 5b 6c | 69 6d 69 74 5d 5d 20 6f |urns [[l|imit]] o|
|00001040| 72 20 5b 5b 73 5d 5d 2c | 20 77 68 69 63 68 65 76 |r [[s]],| whichev|
|00001050| 65 72 20 69 73 20 67 72 | 65 61 74 65 72 2e 0d 3c |er is gr|eater..<|
|00001060| 3c 2a 3e 3e 3d 0d 73 74 | 61 74 69 63 20 76 6f 69 |<*>>=.st|atic voi|
|00001070| 64 20 77 72 69 74 65 5f | 69 6e 64 65 78 5f 75 73 |d write_|index_us|
|00001080| 65 28 76 6f 69 64 20 2a | 63 6c 6f 73 75 72 65 2c |e(void *|closure,|
|00001090| 20 63 68 61 72 20 2a 69 | 64 2c 20 63 68 61 72 20 | char *i|d, char |
|000010a0| 2a 69 6e 73 74 61 6e 63 | 65 29 20 7b 0d 20 20 4c |*instanc|e) {. L|
|000010b0| 69 6e 65 4f 75 74 20 2a | 69 6e 66 6f 20 3d 20 28 |ineOut *|info = (|
|000010c0| 4c 69 6e 65 4f 75 74 20 | 2a 29 20 63 6c 6f 73 75 |LineOut |*) closu|
|000010d0| 72 65 3b 0d 20 20 69 6e | 66 6f 2d 3e 6c 69 6e 65 |re;. in|fo->line|
|000010e0| 20 3d 20 65 6d 69 74 5f | 75 70 5f 74 6f 28 69 6e | = emit_|up_to(in|
|000010f0| 66 6f 2d 3e 6f 75 74 2c | 20 69 6e 66 6f 2d 3e 6c |fo->out,| info->l|
|00001100| 69 6e 65 2c 20 69 6e 73 | 74 61 6e 63 65 29 3b 0d |ine, ins|tance);.|
|00001110| 20 20 66 70 72 69 6e 74 | 66 28 69 6e 66 6f 2d 3e | fprint|f(info->|
|00001120| 6f 75 74 2c 20 22 40 69 | 6e 64 65 78 20 75 73 65 |out, "@i|ndex use|
|00001130| 20 25 73 5c 6e 22 2c 20 | 69 64 29 3b 0d 20 20 69 | %s\n", |id);. i|
|00001140| 6e 66 6f 2d 3e 6c 69 6e | 65 20 3d 20 65 6d 69 74 |nfo->lin|e = emit|
|00001150| 5f 75 70 5f 74 6f 28 69 | 6e 66 6f 2d 3e 6f 75 74 |_up_to(i|nfo->out|
|00001160| 2c 20 69 6e 66 6f 2d 3e | 6c 69 6e 65 2c 20 69 6e |, info->|line, in|
|00001170| 73 74 61 6e 63 65 20 2b | 20 73 74 72 6c 65 6e 28 |stance +| strlen(|
|00001180| 69 64 29 29 3b 0d 7d 0d | 40 20 25 64 65 66 20 77 |id));.}.|@ %def w|
|00001190| 72 69 74 65 5f 69 6e 64 | 65 78 5f 75 73 65 0d 3c |rite_ind|ex_use.<|
|000011a0| 3c 2a 3e 3e 3d 0d 73 74 | 61 74 69 63 20 63 68 61 |<*>>=.st|atic cha|
|000011b0| 72 20 2a 65 6d 69 74 5f | 75 70 5f 74 6f 28 46 49 |r *emit_|up_to(FI|
|000011c0| 4c 45 20 2a 66 2c 20 63 | 68 61 72 20 2a 73 2c 20 |LE *f, c|har *s, |
|000011d0| 63 68 61 72 20 2a 6c 69 | 6d 69 74 29 20 7b 0d 20 |char *li|mit) {. |
|000011e0| 20 69 66 20 28 73 20 3c | 20 6c 69 6d 69 74 29 20 | if (s <| limit) |
|000011f0| 7b 0d 20 20 20 20 63 68 | 61 72 20 73 61 76 65 64 |{. ch|ar saved|
|00001200| 20 3d 20 2a 6c 69 6d 69 | 74 3b 0d 20 20 20 20 2a | = *limi|t;. *|
|00001210| 6c 69 6d 69 74 20 3d 20 | 30 3b 0d 20 20 20 20 66 |limit = |0;. f|
|00001220| 70 72 69 6e 74 66 28 66 | 2c 20 22 40 74 65 78 74 |printf(f|, "@text|
|00001230| 20 25 73 5c 6e 22 2c 20 | 73 29 3b 0d 20 20 20 20 | %s\n", |s);. |
|00001240| 2a 6c 69 6d 69 74 20 3d | 20 73 61 76 65 64 3b 0d |*limit =| saved;.|
|00001250| 20 20 20 20 72 65 74 75 | 72 6e 20 6c 69 6d 69 74 | retu|rn limit|
|00001260| 3b 0d 20 20 7d 20 65 6c | 73 65 20 7b 0d 20 20 20 |;. } el|se {. |
|00001270| 20 72 65 74 75 72 6e 20 | 73 3b 0d 20 20 7d 0d 7d | return |s;. }.}|
|00001280| 0d 3c 3c 6c 6f 63 61 6c | 20 70 72 6f 74 6f 74 79 |.<<local| prototy|
|00001290| 70 65 73 3e 3e 3d 0d 73 | 74 61 74 69 63 20 76 6f |pes>>=.s|tatic vo|
|000012a0| 69 64 20 77 72 69 74 65 | 5f 69 6e 64 65 78 5f 75 |id write|_index_u|
|000012b0| 73 65 28 76 6f 69 64 20 | 2a 63 6c 6f 73 75 72 65 |se(void |*closure|
|000012c0| 2c 20 63 68 61 72 20 2a | 69 64 2c 20 63 68 61 72 |, char *|id, char|
|000012d0| 20 2a 69 6e 73 74 61 6e | 63 65 29 3b 0d 73 74 61 | *instan|ce);.sta|
|000012e0| 74 69 63 20 63 68 61 72 | 20 2a 65 6d 69 74 5f 75 |tic char| *emit_u|
|000012f0| 70 5f 74 6f 28 46 49 4c | 45 20 2a 66 2c 20 63 68 |p_to(FIL|E *f, ch|
|00001300| 61 72 20 2a 73 2c 20 63 | 68 61 72 20 2a 6c 69 6d |ar *s, c|har *lim|
|00001310| 69 74 29 3b 0d 3c 3c 63 | 6f 6d 70 6c 61 69 6e 20 |it);.<<c|omplain |
|00001320| 61 62 6f 75 74 20 6f 70 | 65 6e 69 6e 67 20 74 65 |about op|ening te|
|00001330| 6d 70 20 66 69 6c 65 20 | 61 6e 64 20 65 78 69 74 |mp file |and exit|
|00001340| 3e 3e 3d 0d 65 72 72 6f | 72 6d 73 67 28 46 61 74 |>>=.erro|rmsg(Fat|
|00001350| 61 6c 2c 20 22 25 73 3a | 20 63 6f 75 6c 64 6e 27 |al, "%s:| couldn'|
|00001360| 74 20 6f 70 65 6e 20 74 | 65 6d 70 6f 72 61 72 79 |t open t|emporary|
|00001370| 20 66 69 6c 65 5c 6e 22 | 29 3b 0d 3c 3c 63 6f 6d | file\n"|);.<<com|
|00001380| 70 6c 61 69 6e 20 61 62 | 6f 75 74 20 77 72 69 74 |plain ab|out writ|
|00001390| 69 6e 67 20 74 65 6d 70 | 20 66 69 6c 65 20 61 6e |ing temp| file an|
|000013a0| 64 20 65 78 69 74 3e 3e | 3d 0d 65 72 72 6f 72 6d |d exit>>|=.errorm|
|000013b0| 73 67 28 46 61 74 61 6c | 2c 20 22 25 73 3a 20 65 |sg(Fatal|, "%s: e|
|000013c0| 72 72 6f 72 20 77 72 69 | 74 69 6e 67 20 74 65 6d |rror wri|ting tem|
|000013d0| 70 6f 72 61 72 79 20 66 | 69 6c 65 5c 6e 22 29 3b |porary f|ile\n");|
|000013e0| 0d | |. | |
+--------+-------------------------+-------------------------+--------+--------+